# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libmpcdec
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.2.6
pkgrel=3
pkgdesc="Musepack decoding library (mingw-w64)"
arch=("any")
url="https://musepack.net/"
license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
source=("https://files.musepack.net/source/${_realname}-${pkgver}.tar.bz2")
sha256sums=('4bd54929a80850754f27b568d7891e1e3e1b8d2f208d371f27d1fda09e6f12a8')

prepare() {
  cd ${_realname}-${pkgver}
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

check() {
  cd build-${MINGW_CHOST}
  make -k check
}

package() {
  cd build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
  install -Dm644 ${srcdir}/${_realname}-${pkgver}/COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
